﻿<?php
error_reporting(0);
require_once "../../../../../../../sys/install/config.dbu.php";
require_once "../../../../../../../sys/classes/connDBClass.php"; // for db class

if(!session_id()){
	session_start();
}
$creatorID = $_SESSION['uid'];

if ($creatorID == 'admin') 
	$creatorID = 0;

	$db = new connDB($CONST['DB_HOST'], $CONST['DB_LOGIN'], $CONST['DB_PWD'], $CONST['DB_NAME_CRM']);
	
	$dataTable = array();
	$dataTable[] = "'[salespage/a]'";
	$dataTable[] = "'[salespage/b]'";
	$dataTable[] = "'[salespage/c]'";
	$dataTable[] = "'[salespage/d]'";
				
	$dataTable[] = "'[first_name]'";
	$dataTable[] = "'[last_name]'";
	$dataTable[] = "'[members_email]'";
	$dataTable[] = "'[members_name]'";				
	

	
	$rs = $db->query("SELECT a.name, a.label FROM email_form_questions AS a, email_form_answer AS b WHERE a.created_by = " .$creatorID. " AND a.aid= b.id AND a.isdeleted = 0 AND b.isdeleted = 0 ORDER BY a.name");
	if ($db->count($rs) > 0) {
		while ($data = $db->fetch($rs)) {
			$dataTable[] = "'[".$data['name']."]'";
		}
	}
	$data = join(",", $dataTable);

?>



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.dialog.add('fileicon',function(a){var b,c=a.lang.specialChar,d=function(k){var l=a.getSelection(),m=l.getRanges(),n,o;a.fire('saveSnapshot');for(var p=0,q=m.length;p<q;p++){n=m[p];n.deleteContents();o=CKEDITOR.dom.element.createFromHtml(k);n.insertNode(o);}n.moveToPosition(o,CKEDITOR.POSITION_AFTER_END);n.select();a.fire('saveSnapshot');},e=function(k){var l,m;if(k.data)l=k.data.getTarget();else l=new CKEDITOR.dom.element(k);if(l.getName()=='a'&&(m=l.getChild(0).getHtml())){l.removeClass('cke_light_background');b.hide();if(CKEDITOR.env.gecko)d(m);else a.insertHtml(m);}},f=CKEDITOR.tools.addFunction(e),g,h=function(k,l){var m;l=l||k.data.getTarget();if(l.getName()=='span')l=l.getParent();if(l.getName()=='a'&&(m=l.getChild(0).getHtml())){if(g)i(null,g);var n=b.getContentElement('info','htmlPreview').getElement();b.getContentElement('info','charPreview').getElement().setHtml(m);n.setHtml(CKEDITOR.tools.htmlEncode(m));l.getParent().addClass('cke_light_background');g=l;}},i=function(k,l){l=l||k.data.getTarget();if(l.getName()=='span')l=l.getParent();if(l.getName()=='a'){b.getContentElement('info','charPreview').getElement().setHtml('&nbsp;');b.getContentElement('info','htmlPreview').getElement().setHtml('&nbsp;');l.getParent().removeClass('cke_light_background');g=undefined;}},j=CKEDITOR.tools.addFunction(function(k){k=new CKEDITOR.dom.event(k);var l=k.getTarget(),m,n,o=k.getKeystroke(),p=a.lang.dir=='rtl';switch(o){case 38:if(m=l.getParent().getParent().getPrevious()){n=m.getChild([l.getParent().getIndex(),0]);n.focus();i(null,l);h(null,n);}k.preventDefault();break;case 40:if(m=l.getParent().getParent().getNext()){n=m.getChild([l.getParent().getIndex(),0]);if(n&&n.type==1){n.focus();i(null,l);h(null,n);}}k.preventDefault();break;case 32:e({data:k});k.preventDefault();break;case p?37:39:case 9:if(m=l.getParent().getNext()){n=m.getChild(0);if(n.type==1){n.focus();i(null,l);h(null,n);k.preventDefault(true);}else i(null,l);}else if(m=l.getParent().getParent().getNext()){n=m.getChild([0,0]);if(n&&n.type==1){n.focus();i(null,l);h(null,n);k.preventDefault(true);}else i(null,l);}break;case p?39:37:case CKEDITOR.SHIFT+9:if(m=l.getParent().getPrevious()){n=m.getChild(0);n.focus();i(null,l);h(null,n);k.preventDefault(true);}else if(m=l.getParent().getParent().getPrevious()){n=m.getLast().getChild(0);n.focus();i(null,l);h(null,n);k.preventDefault(true);}else i(null,l);break;default:return;}});return{title:'Insert Personalized tags',minWidth:430,minHeight:280,buttons:[CKEDITOR.dialog.cancelButton],charColumns:3,
chars:[<?php echo $data; ?>],onLoad:function(){var k=this.definition.charColumns,l=this.definition.chars,m='specialchar_table_label'+CKEDITOR.tools.getNextNumber(),n=['<table role="listbox" aria-labelledby="'+m+'"'+' style="width: 420px; height: 100%; border-collapse: separate;"'+' align="center" cellspacing="2" cellpadding="2" border="0">'],o=0,p=l.length,q,r;
while(o<p){n.push('<tr>');for(var s=0;s<k;s++,o++){if(q=l[o]){r='';q=q.replace(/\((.*?)\)/,function(u,v){r=v;return '';});r=r||q;var t='cke_specialchar_label_'+o+'_'+CKEDITOR.tools.getNextNumber();n.push('<td class="cke_dark_background" style="cursor: default" role="presentation"><a href="javascript: void(0);" role="option" aria-posinset="'+(o+1)+'"',' aria-setsize="'+p+'"',' aria-labelledby="'+t+'"',' style="cursor: inherit; display: block; height: 1.25em; margin-top: 0.25em; text-align: center;" title="',CKEDITOR.tools.htmlEncode(r),'" onkeydown="CKEDITOR.tools.callFunction( '+j+', event, this )"'+' onclick="CKEDITOR.tools.callFunction('+f+', this); return false;"'+' tabindex="-1">'+'<span style="margin: 0 auto;cursor: inherit">'+q+'</span>'+'<span class="cke_voice_label" id="'+t+'">'+r+'</span></a>');}else n.push('<td class="cke_dark_background">&nbsp;');n.push('</td>');}n.push('</tr>');}n.push('</tbody></table>','<span id="'+m+'" class="cke_voice_label">'+c.options+'</span>');this.getContentElement('info','charContainer').getElement().setHtml(n.join(''));},contents:[{id:'info',label:a.lang.common.generalTab,title:a.lang.common.generalTab,padding:0,align:'top',elements:[{type:'hbox',align:'top',widths:['420px','90px'],children:[{type:'html',id:'charContainer',html:'',onMouseover:h,onMouseout:i,focus:function(){var k=this.getElement().getElementsByTag('a').getItem(0);setTimeout(function(){k.focus();h(null,k);});},onShow:function(){var k=this.getElement().getChild([0,0,0,0,0]);setTimeout(function(){k.focus();h(null,k);});},onLoad:function(k){b=k.sender;}},{type:'hbox',align:'top',widths:['100%'],children:[{type:'vbox',align:'top',children:[{type:'html',html:'<div></div>'},{type:'html',id:'charPreview',className:'cke_dark_background',style:"border:1px solid #eeeeee;font-size:18px;height:40px;width:150px;padding-top:9px;font-family:'Microsoft Sans Serif',Arial,Helvetica,Verdana;text-align:center;",html:'<div>&nbsp;</div>'},{type:'html',id:'htmlPreview',className:'cke_dark_background',style:"border:1px solid #eeeeee;font-size:14px;height:20px;width:150px;padding-top:2px;font-family:'Microsoft Sans Serif',Arial,Helvetica,Verdana;text-align:center;",html:'<div>&nbsp;</div>'}]}]}]}]}]};});